<template>
  <div class="recommend">
    <div
      class="recommend-item"
      v-for="(item, index) in recommends.slice(0,4)"
      :key="index"
    >
      <a href="" @click.prevent="goD(item.id)">
        <img v-lazy="item.cover_url" alt="" />
        <div>{{ item.title }}</div>
      </a>
    </div>
  </div>
</template>
<script>
import {useRouter} from 'vue-router'
export default {
  props: {
    recommends: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  setup(){
      const router=useRouter()
      const goD=(id)=>{
          router.push({path:'/detail',query:{id}})
      }
      return{
          goD
      }
  }
};
</script>
<style lang="less" scoped>
.recommend {
  display: flex;
  width: 100%;
  text-align: center;
  padding: 15px 0 30px;
  border-bottom: 8px solid #eee;
  .recommend-item {
    flex: 1;
    font-size: 12px;
    img {
      width: 70px;
      height: 70px;
      margin-bottom: 10px;
    }
  }
}
</style>